/**
 * Created by qqlai on 2016/11/22.
 */
{
    angular.module('studentPersonModule')
        .controller('studentPersonController',studentPersonController);
    studentPersonController.$inject = ['http.interfaces','$stateParams','$location',"$scope"];
    function studentPersonController(interfaces,$stateParams,$location,$scope) {
        let vm = this;
        let collect = {
            inputValue:'',
            toggle:false,
            info:{},
            id:'',
            urlcs:'',
            active1:false,
            active2:false,
            xs:false,
            tab1:tab1,
            tab2:tab2,
            studentInfo:false,
            active: Active,
            search:search,
            logout:logout
        };
        collect.active();//进入控制器后调用一次
        vm.collect = collect;//输出集合，提供给模板调用


        /** Active方法
         * @desc 控制器触发时执行一次的方法
         * @constructor
         */
        function Active() {
            $scope.$on('$ionicView.beforeEnter', function (event, data) {
                collect.urlcs=$location.url().split("=");
                collect.id=collect.urlcs[1];
                if(!!$stateParams.id){
                    collect.id=$stateParams.id;
                }
                search();
            });
        }
        function search() {
            interfaces.studentSearch({stuId:collect.id}).then(res=> {
                if(res.data.resultCode==1){
                console.log(res.data);
                var myData = res.data;
                    if (myData.data.length == 0) {
    
                    }else{
                        collect.info=myData.data;
                        console.log(collect.info)
                    }
                }
            });
        }
        function logout() {
            interfaces.logout();
        }
        
        function tab1() {
            collect.xs=false;
            collect.active1=false;
            collect.active2=false;
            collect.studentInfo=false;
        }
        function tab2() {
            collect.xs=true;
            collect.studentInfo=true;
            collect.active1=true;
            collect.active2=true;
        }
    }
}